<?php
namespace Api\Controller;
/**
 * 文章
 */
class ArticleController extends ApiController
{
    protected $noCheck = [];

    function _initialize() {
        parent::_initialize();
    }

    /**
     * 点赞
     */
    public function like()
    {
        $id = I('id');
        $res = like_log($this->uid, 1 , $id);
        if($res['status']){
            $this->ajaxReturn(['s'=>true, 'm'=>'点赞成功']);
        }else{
            $this->ajaxReturn(['s'=>false, 'm'=>$res['msg']]);
        }

        $id = I('id');
        $info = M('article')->where(['id'=>$id])->find();
        if(empty($info)){
            $this->ajaxReturn(['s'=>false, 'm'=>'内容不存在']);
        }
        $res = M('article')->where(['id'=>$id])->setInc('like_num', 1);
        if($res){
            $this->ajaxReturn(['s'=>true, 'm'=>'点赞成功']);
        }else{
            $this->ajaxReturn(['s'=>false, 'm'=>'点赞失败']);
        }
    }
}